package com.yanqu.road.server.cmd.zhaoshang;

import com.yanqu.road.entity.enums.eBigRankType;
import com.yanqu.road.entity.rank.cross.CrossUserRank;
import com.yanqu.road.logic.pb.CrossRankPb;
import com.yanqu.road.pb.zhaoshang.ZhaoShangProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.zhaoshang.ZsRankMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_ZHAO_SHANG_RANK_CHANGE, desc = "排行数据变化")
public class ZsWeekRankChangeCmd extends CrossCommand {

    private int weekId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ZhaoShangProto.CrossZsWeekRankChangeReqMsg reqMsg = ZhaoShangProto.CrossZsWeekRankChangeReqMsg.parseFrom(packet.getBytes());
        weekId = reqMsg.getWeekId();

        int groupId = ZsRankMgr.getGroupId(serverId);
        for(ZhaoShangProto.ZsWeekRankTemp rankTemp: reqMsg.getDataListList()){
            CrossUserRank crossUserRank = CrossRankPb.parseCrossUserRank(rankTemp.getRankType(), rankTemp.getData(),  eBigRankType.Normal.getValue());
            ZsRankMgr.changeUserRank(groupId, weekId, eBigRankType.Normal.getValue(), rankTemp.getRankType(), crossUserRank);
        }
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
